package pattern.behavioral.iterator.simple;

/**
 * @author: chaoyang.ren  
 * @date:Jun 5, 2017  
 * @time:11:34:47 AM   
 * @email:chaoyang.ren@foxmail.com  
 * @version: 1.0
 */
public class MyCollection<E> implements Collection<E> {
	private E[] objectArray = null;
	
	public MyCollection(E[] objectArray){
		this.objectArray = objectArray;
	}
	
	public Iterator<E> iterator() {
		return new MyIterator<E>(this);
	}

	public int size() {
		return this.objectArray.length;
	}

	public E getElement(int index) {
		return objectArray[index];
	}

	public E[] toArray() {
		return objectArray;
	}

}

